import request from '@/utils/request'


// 查询设备信息列表
export function listDevice(query) {
  return request({
    url: '/device/device/list',
    method: 'get',
    params: query
  })
}

// 查询设备信息列表
export function listDeviRoAla(query) {
  return request({
    url: '/device/device/listDeviRoAla',
    method: 'get',
    params: query
  })
}

// 查询设备信息详细
export function getDevice(id) {
  return request({
    url: '/device/device/' + id,
    method: 'get'
  })
}

// 新增设备信息
export function addDevice(data) {
  return request({
    url: '/device/device',
    method: 'post',
    data: data
  })
}

// 修改设备信息
export function updateDevice(data) {
  return request({
    url: '/device/device',
    method: 'put',
    data: data
  })
}

// 删除设备信息
export function delDevice(id) {
  return request({
    url: '/device/device/' + id,
    method: 'delete'
  })
}

// 导出设备信息
export function exportDevice(query) {
  return request({
    url: '/device/device/export',
    method: 'get',
    params: query
  })
}

// 根据设备编号查询 用于表单校验是否重复
export function selectDeviceCode(deviceCode,id){
	return request({
		url: '/device/device/selectDeviceCode/'+deviceCode+'/'+id,
		mothod: 'get'
	})
}


// 设备状态修改
export function changeDeviceStatus(id, status,type) {
  const data = {
    id,
    status,
    type
  }
  return request({
    url: '/device/device/changeStatus',
    method: 'put',
    data: data
  })
}

// 获取所有设备信息
export function selectDevicelist(roomId,productId,nodeType) {
  return request({
    url: '/device/device/selectDevicelist',
    method: 'post',
    data:{
    	roomId:	roomId,
      productId:productId,
      nodeType:nodeType,
    }
  })
}

// 查询设备信息详细
export function selectProAndDevTotals() {
  return request({
    url: '/device/device/selectProAndDevTotals',
    method: 'get'
  })
}

// 同步设备数据到设备
export function deviceParamToDev(id) {
  return request({
    url: '/device/device/deviceParamToDev/' + id,
    method: 'get'
  })
}


// 设备树
export function selectDeviceTree(productType) {
  return request({
    url: '/device/device/selectDeviceTree',
    method: 'post',
    data:{
      productType:productType
    }
  })
}

// 设备配置接口
export function selectIdsDevice(id) {
  return request({
    url: '/device/device/selectIdsDevice/'+id,
    method: 'get'
  })
}
// 导入智能锁设备
export function importLockDeviceList(data) {
  return request({
    url: '/device/device/importLockDeviceList/',
    method: 'post',
    data: data
  })
}
